<?php	 	 

/**
 * This is the model class for table "pesan".
 *
 * The followings are the available columns in table 'pesan':
 * @property integer $id
 * @property integer $id_menu
 * @property integer $id_laporan
 * @property string $pesan
 * @property integer $pembuat
 * @property string $tanggal_pembuatan
 *
 * The followings are the available model relations:
 * @property Users $pembuat0
 * @property PelaporanKeuanganDanBmn $idLaporan
 */
class Pesan extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Pesan the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pesan';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_menu, id_laporan, pembuat', 'numerical', 'integerOnly'=>true),
			array('pesan, tanggal_pembuatan', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, id_menu, id_laporan, pesan, pembuat, tanggal_pembuatan', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'pembuat0' => array(self::BELONGS_TO, 'User', 'pembuat'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_menu' => 'Id Menu',
			'id_laporan' => 'Id Laporan',
			'pesan' => 'Pesan',
			'pembuat' => 'Pembuat',
			'tanggal_pembuatan' => 'Tanggal Pembuatan',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_menu',$this->id_menu);
		$criteria->compare('id_laporan',$this->id_laporan);
		$criteria->compare('pesan',$this->pesan,true);
		$criteria->compare('pembuat',$this->pembuat);
		$criteria->compare('tanggal_pembuatan',$this->tanggal_pembuatan,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}